<?php
/**
 *   点赞 / 阅读量
 *   @param 
 *   @date 2019/12/5
 *   @author Xiaohui Zeng
 */

namespace app\blog\controller;


use app\model\CmsContent;

class LikeClick extends Base
{
    /**
     *   点赞
     *   @param $id 文章id
     *   @date 2019/12/5
     *   @author Xiaohui Zeng
     */
    public function like () {
        $id = $this->request->get('id');
        if(strlen($id)) {
            $w = CmsContent::get($id);
            $w->likenum= ['inc', 1];
            $w->save();
            return $this->buildSuccess([
                'likenum'  => CmsContent::get($id)->likenum
            ]);
        }
    }
    /**
     *   阅读量
     *   @param
     *   @date 2019/12/5
     *   @author Xiaohui Zeng
     */
    public function click () {
        $id = $this->request->get('id');
        if(strlen($id)) {
            $w = CmsContent::get($id);
            $w->onclick= ['inc', 1];
            $w->save();
            return $this->buildSuccess();
        }
    }
}